/*************************************************
 * 
 * Copyright by Bruno Eberhard
 * 
 * Created on 31.07.2005
 *
 *************************************************/
package fightplan.business;

import java.awt.Color;
import java.io.Serializable;

public enum Gender implements Serializable, Comparable<Gender> {
	H("H", "Herren", "Knaben", new Color(200, 200, 255)), D("D", "Damen", "Mädchen", new Color(255, 200, 200)), UNSET(
			"U", "Unbestimmt", "Unbestimmt", new Color(200, 200, 200)), ALL("Alle", "Alle", "Alle", new Color(200, 255,
			200));

	private static final long serialVersionUID = 1;

	public static final Gender[] ALL_VALUES = new Gender[] { H, D, UNSET, ALL };
	public static final Gender[] VALUES = new Gender[] { H, D };
	public static final Gender[] VALUES_AND_UNSET = new Gender[] { UNSET, H, D };
	public static final Gender[] VALUES_AND_ALL = new Gender[] { ALL, H, D };

	private String name;
	private String nameLong;
	private String nameLongChildern;
	private Color color;

	Gender(String name, String nameLong, String nameLongChildren, Color color) {
		this.name = name;
		this.nameLong = nameLong;
		this.nameLongChildern = nameLongChildren;
		this.color = color;
	}

	public static Gender parse(String s) {
		if (s == null || s.length() == 0)
			return UNSET;

		String firstChar = s.substring(0, 1);
		if (firstChar.equalsIgnoreCase("D") || firstChar.equalsIgnoreCase("W") || firstChar.equalsIgnoreCase("F")) {
			return D;
		} else if (firstChar.equalsIgnoreCase("H") || firstChar.equalsIgnoreCase("M")) {
			return H;
		} else if (firstChar.equalsIgnoreCase("A")) {
			return ALL;
		}

		return UNSET;
	}

	// get / set

	public String getName() {
		return name;
	}

	public String getNameLong() {
		return nameLong;
	}

	public String getNameLongChildren() {
		return nameLongChildern;
	}

	public Color getColor() {
		return color;
	}

	//

	public boolean comaptible(Gender g) {
		return ALL.equals(this) || equals(g);
	}

}
